home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / QTRAP.DEM < prev    next >
Text File  |  1991-04-29  |  720b  |  36 lines

  1. PROGRAM d4r2(input,output);
  2. (* driver for routine QTRAP *)
  3. CONST
  4.    pio2=1.5707963;
  5. VAR
  6.    glit : integer;
  7.    a,b,s : real;
  8.  
  9. FUNCTION func(x : real) : real;
  10. (* Test function *)
  11. BEGIN
  12.    func := sqr(x)*(sqr(x)-2.0)*sin(x)
  13. END;
  14.  
  15. FUNCTION fint(x : real) : real;
  16. (* Integral of test function *)
  17. BEGIN
  18.    fint := 4.0*x*(sqr(x)-7.0)*sin(x)-
  19.          (sqr(sqr(x))-14.0*sqr(x)+28.0)*cos(x);
  20. END;
  21.  
  22. (*$I MODFILE.PAS *)
  23. (*$I TRAPZD.PAS *)
  24.  
  25. (*$I QTRAP.PAS *)
  26.  
  27. BEGIN
  28.    a := 0.0;
  29.    b := pio2;
  30.    writeln ('Integral of func computed with QTRAP');
  31.    writeln;
  32.    writeln ('Actual value of integral is',fint(b)-fint(a):12:6);
  33.    qtrap(a,b,s);
  34.    writeln ('Result from routine QTRAP is',s:12:6);
  35. END.
  36.